package com.gs.process.admin.controller;

import com.gs.process.admin.context.ProcessContext;
import com.gs.process.core.configuration.ProcessConfig;
import com.shallowUniverse.logs.annotation.AutoLog;
import com.shallowUniverse.web.BaseController;
import com.shallowUniverse.web.annotation.AutoReturn;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author: Shuai Guo
 * @description:
 * @date: 2021/9/29
 * @version: 1.0
 */
@Controller
@RequestMapping("/receive")
public class ReceiveController extends BaseController {

    @Resource
    private ProcessContext processContext;

    @AutoLog
    @AutoReturn
    @PostMapping("/users")
    public void receiveUser(@RequestBody Map<String, List<Map<String, Object>>> dataMapping) {
        processContext.init(dataMapping);
        this.submit(true, null);
    }

    @AutoLog
    @AutoReturn
    @PostMapping("/config")
    public void receiveConfig(@RequestBody ProcessConfig processConfig) {
        processContext.setConfig(processConfig);
        this.submit(true, null);
    }
}
